﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ChessSuite.Utilities.Common.Enumeations;

namespace ChessSuite.Utilities.Common.Utilities
{
    public static partial class PieceTypeUtility
    {
        public static bool Contains(this PieceType piece, PieceType value)
        {
            return value.Count(PieceType.Pawn) <= piece.Count(PieceType.Pawn) &&
                value.Count(PieceType.Bishop) <= piece.Count(PieceType.Bishop) &&
                value.Count(PieceType.Knight) <= piece.Count(PieceType.Knight) &&
                value.Count(PieceType.Rook) <= piece.Count(PieceType.Rook) &&
                value.Count(PieceType.Queen) <= piece.Count(PieceType.Queen) &&
                value.Count(PieceType.King) <= piece.Count(PieceType.King);
        }

        public static bool Contains(this PieceType piece, IEnumerable<PieceType> value)
        {
            return value.Count(PieceType.Pawn) <= piece.Count(PieceType.Pawn) &&
                value.Count(PieceType.Bishop) <= piece.Count(PieceType.Bishop) &&
                value.Count(PieceType.Knight) <= piece.Count(PieceType.Knight) &&
                value.Count(PieceType.Rook) <= piece.Count(PieceType.Rook) &&
                value.Count(PieceType.Queen) <= piece.Count(PieceType.Queen) &&
                value.Count(PieceType.King) <= piece.Count(PieceType.King);
        }

        public static bool Contains(this IEnumerable<PieceType> piece, PieceType value)
        {
            return value.Count(PieceType.Pawn) <= piece.Count(PieceType.Pawn) &&
                value.Count(PieceType.Bishop) <= piece.Count(PieceType.Bishop) &&
                value.Count(PieceType.Knight) <= piece.Count(PieceType.Knight) &&
                value.Count(PieceType.Rook) <= piece.Count(PieceType.Rook) &&
                value.Count(PieceType.Queen) <= piece.Count(PieceType.Queen) &&
                value.Count(PieceType.King) <= piece.Count(PieceType.King);
        }

        public static bool Contains(this IEnumerable<PieceType> piece, IEnumerable<PieceType> value)
        {
            return value.Count(PieceType.Pawn) <= piece.Count(PieceType.Pawn) &&
                value.Count(PieceType.Bishop) <= piece.Count(PieceType.Bishop) &&
                value.Count(PieceType.Knight) <= piece.Count(PieceType.Knight) &&
                value.Count(PieceType.Rook) <= piece.Count(PieceType.Rook) &&
                value.Count(PieceType.Queen) <= piece.Count(PieceType.Queen) &&
                value.Count(PieceType.King) <= piece.Count(PieceType.King);
        }
    }
}
